import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
  { 
    path: '/Login',
    //路由 
    name: 'Login',//名称 
    component: () => import('../views/Login.vue')//页面 
  },
  {
  path: '/Home',
  name: 'Home',
  component: () => import('../views/Home.vue'),
  redirect: '/Admin', //默认加载页面
  children: [
    {
      path: '/Admin',
      name: 'Admin',
      component: () => import('../views/Admin.vue')
    },
    {
      path: '/Order',
      name: 'Order',
      component: () => import('../views/Order.vue')
    },
    {
      path: '/Total',
      name: 'Total',
      component: () => import('../views/Total')
    },
    {
      path: '/AdminEdit',
      name: 'AdminEdit',
      component: () => import('../views/AdminEdit')
    },
    {
      path: '/OrderView',
      name: 'OrderView',
      component: () => import('../views/OrderView')
    }
  ]
  },
  {
    path:'*',
    component:()=>import('../views/NotFound')
  },
  {
    path: '/Admin',
    name: 'Admin',
    component: () => import('../views/Admin.vue'),
    meta:{ role:'超级管理员' }
  },
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// 解决重复点击相同路由报错 Error: Avoided redundant navigation to current location:
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router